// Copyright (c) 2023 Presto Labs Pte. Ltd.
// Author: tianqiang

#include "coin2/exchange/uniswap/api_order/grpc/grpc_subscriber.h"

namespace coin2::exchange::uniswap::api_order::grpc {

void UniswapGrpcSubscriber::QueryAccountBalance(const std::set<std::string>& currencies) {
  grpc_client()->QueryAccountBalance(currencies);
}

void UniswapGrpcSubscriber::QueryNftTokenInfo(const std::string& symbol) {
  grpc_client()->QueryNftTokenInfo(symbol);
}

void UniswapGrpcSubscriber::SubscribeAsync() {
  AddPeriodicTask(
      std::bind(
          &UniswapGrpcSubscriber::QueryAccountBalance,
          this,
          symcache_->GetCurrenciesNativeUpper()),
      config_.query_account_balance_period_sec(),
      "query_account_balance");

  const auto symbol_list = native_symbols();

  AddPeriodicTask(
      std::bind(&UniswapGrpcSubscriber::QueryNftTokenInfo, this, std::placeholders::_1),
      config_.query_account_balance_period_sec(),
      "query_nft_token_info",
      symbol_list);
}

}  // namespace coin2::exchange::uniswap::api_order::grpc
